package main

import (
	"fmt"
	gimclient "gim-client"
	"time"
)

func main() {

	config, err := gimclient.InitConfig("./config.yaml")
	if err != nil {
		fmt.Println("初始化配置错误")
		return
	}
	gimclient.InitLog(config.Log.FilePath)
	gimclient.InitResource()
	brokerOption := &gimclient.BrokerOption{Endpoint: config.GimBroker.Endpoint, ConnectTimeOut: config.GimBroker.ConnectTimeOut}
	go func() {
		time.Sleep(time.Duration(brokerOption.ConnectTimeOut + 1))
		gimclient.Logger.Info("success connect gim-broker")
	}()
	go func() {
		err = brokerOption.ConnectBroker()
		if err != nil {
			gimclient.Logger.Error("fail connect gim-broker")
		}
	}()
	gimclient.RunHttp(config.Http.Port)
}
